How One Programmer Broke the Internet by Deleting a Tiny Piece of Code
That code can be used to add characters to the beginning of a string of text, perhaps a zero to the beginning of a zip code. It’s a single-purpose function, simple enough for most programmers to write themselves. Lots of npm packages, however, relied on left-pad to do it for them, which is how this tiny bit of code became so important.
Some of the largest, most widely used npm packages in the world were suddenly broken. One of the affected packages, React, is used by major websites like Facebook, which created it, and a wide variety of smaller sites like Quartz’s own Atlas. In the past month alone, more than a million people have downloaded React from npm. React didn’t require these 11 lines of code directly, of course. It depended on one set of packages, and each of those depended on another set, et cetera, and one of those branches eventually led to left-pad. And now, left-pad was gone.
It absence was felt globally; the commenters on left-pad’s GitHub page were writing from Australia, Germany, the United States, and the Czech Republic. In Ontario, where the issue had originated in its roundabout way, programmers at Kik were ironically running into left-pad problems, as well. Mike Roberts, who runs the company’s messaging app, said in an interview that the error prevented his colleagues from running software they had been working on. “What the heck,” Roberts recalled thinking, “one of our packages is missing?”
More: How one programmer broke the internet by deleting a tiny piece of code